<template>
  <div class="header1">
    <div>
      <i
        class="iconfont icon-xiangzuo"
        v-if="$route.name == 'Item'"
        @click="goHome"
      ></i>
    </div>
    <!-- 使用插槽 -->
    <div><slot></slot></div>
    <div>
      <i class="iconfont icon-hanbaobao" v-if="$route.name != 'Item'"></i>
    </div>
  </div>
</template>
<script>
export default {
  name: "Header1",
  data() {
    return {};
  },
  methods: {
    goHome: function () {
      this.$router.push("/");
    },
  },
  mounted() {
    console.log(this.$route);
  },
};
</script>
<style scoped>
.icon-xiangzuo {
  font-size: 30px;
}
.header1 {
  width: 100%;
  height: 50px;
  line-height: 50px;
  background: #e54847;
  color: #fff;
  display: flex;
  justify-content: space-around;
  text-align: center;
}
.header1 div:nth-of-type(1) {
  width: 10%;
}
.header1 div:nth-of-type(2) {
  width: 80%;
  font-size: 18px;
}
.header1 div:nth-of-type(3) {
  width: 10%;
}
</style>